package com.bckj.fastboot.flowable.controller;

import com.bckj.fastboot.flowable.proc.operation.ProcContext;
import com.bckj.fastboot.flowable.proc.operation.ProcCreateOperation;
import com.bckj.fastboot.flowable.model.ProcCreateRequest;
import com.bckj.fastboot.flowable.service.FastProcessService;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequiredArgsConstructor
@RequestMapping("fast-process")
public class FastProcessController {

    private final FastProcessService fastProcessService;
    @Resource
    private ProcCreateOperation procCreateOperation;

    @PostMapping("deploy")
    public String deploy(MultipartFile file) {
        fastProcessService.deploy(file);
        return "ok";
    }

    @PostMapping("create")
    public String create(ProcCreateRequest request) {
        var ctx = new ProcContext();
        ctx.setRequest(request);
        procCreateOperation.execute(ctx);
        return "ok";
    }
}
